#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
int b[N];
struct Seg {
  int l, r;
} c[N];
bool cmp(int x, int y) {
  if (a[x] != a[y]) return a[x] < a[y];
  return x < y;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) b[i] = i;
  sort(b + 1, b + n + 1, cmp);
  int i = 1, t = 0;
  while (i <= n) {
    int j = i + 1;
    while (j <= n && a[b[j]] == a[b[i]]) j++;
    c[++t] = {b[i], b[j - 1]};
    i = j;
  }
  int ans = 0;
  int dir = -1;
  int pre = c[1].l;
  rep(i, 2, t) {
    if (dir == -1) {
      if (pre > c[i].r)
        pre = c[i].l;
      else
        dir = 1, pre = c[i].r;
    } else {
      if (pre < c[i].l)
        pre = c[i].r;
      else
        ans++, dir = -1, pre = c[i].l;
    }
  }
  ans++;
  cout << ans;
  return 0;
}